console_static_text
Crate for logging text that should stay in the same place in a console. This measures words to handle wrapping and has some console resizing support. Example use might be for displaying progress bars or rendering selections.
Example use with the console crate:
use ConsoleSize;
use ConsoleStaticText;
let mut static_text = new;
static_text.eprint;
sleep_ms;
// will clear the previous text and put this new text
static_text.eprint;
sleep_ms;
// or get and output the text manually
if let Some = static_text.render
// clear out the previous text
static_text.eprint_clear;
Hanging indentation
To get hanging indentation, you can use the lower level "items" api.
static_text.eprint_items;
This is useful when implementing something like a selection UI where you want text to wrap with hanging indentation.
"sized" feature
By default, this crate encourages you to use your own functionality for getting the console size since you'll likely already have a dependency that does that, but if not, then you can use the sized
Cargo.toml feature.
[]
= { = "...", = ["sized"] }
Then you can use the new_sized
function, which will get the console size automatically:
let mut static_text = new_sized;
static_text.eprint;
sleep_ms;
static_text.eprint;